import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { IonSlides } from '@ionic/angular';
import { map } from 'rxjs/internal/operators';
import { Banner, SheetList, SongSheet } from 'src/app/services/conmmon.type';
import { HomeService, SheetParams } from 'src/app/services/home.service';

@Component({
  selector: 'app-music',
  templateUrl: './music.component.html',
  styleUrls: ['./music.component.scss'],
})
export class MusicComponent implements OnInit {

  @ViewChild('homeSlides') homeSlides: IonSlides;

  slideOpts = {
    initialSlide: 0,
    speed: 400,
    autoplay: true,
    loop: true,
  };


  banners: Banner[];
  tjSheet: SongSheet[];

  mySheets: SheetList;
  omSheets: SheetList;

  constructor(
    private homeService: HomeService,
    private route: ActivatedRoute,
    private router: Router
  ) {
    this.route.data.pipe(map(res => res.musicDatas)).subscribe(([banners, tjSheet, mySheets, omSheets]) => {
      this.banners = banners;
      this.tjSheet = tjSheet;
      this.mySheets = mySheets;
      this.omSheets = omSheets;
    })


  }

  ngOnInit() { }


  onAutoplay() {
    this.homeSlides.startAutoplay();
  }

  onPlay(id) {
    console.log("id:", id);

  }
}
